package org.aiesec.fortaleza.xmatch.model.exceptions;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

@SuppressWarnings("serial")
public class XMatchDomainException extends RuntimeException {
	public enum TypeMessage {
		INFO, ERROR, WARNING, FATAL
	}

	private Throwable parent;

	private List<XMatchMessageException> messages = new ArrayList<XMatchMessageException>();

	public XMatchDomainException(XMatchMessageException xMatchMessageException) {
		addMessage(xMatchMessageException);
	}

	public XMatchDomainException(XMatchMessageException xMatchMessageException,
			Throwable parent) {
		addMessage(xMatchMessageException);
		this.parent = parent;
	}

	public XMatchDomainException(Throwable parent) {
		this(
				new XMatchMessageException("msg.default.error",
						TypeMessage.ERROR), parent);
	}

	public void addMessage(XMatchMessageException xMatchMessageException) {
		if (messages == null) {
			messages = new ArrayList<XMatchMessageException>();
		}
		messages.add(xMatchMessageException);
	}

	public XMatchDomainException() {

	}

	public void setParent(Throwable parent) {
		this.parent = parent;
	}

	public Throwable getParent() {
		return parent;
	}

	public List<XMatchMessageException> getMessages() {
		return Collections.unmodifiableList(messages);
	}

}
